<?php
// @formatter:off
/**
 * @file rt.links.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-05-24 23:14:00 +0000 (Fri, 24 May 2013) $
 *
 * $Id: rt.links.php 66 2013-05-24 23:14:00Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.2/extensions/UserAvatar/rt.links.php $
 */
// @formatter:on

function UserAvatar_linkChecker() {
	global $wcSubUser;
	global $wcUser;
	//
	// Only index, mobile and others are not allowed.
	$ok = defined("__INDEX__");
	//
	// There should be a user to modify, if not a specified one, at list the
	// current one.
	$user = $wcSubUser ? $wcSubUser : $wcUser;
	$ok = $ok && $user;
	//
	// Tell me you have clearance!.
	if($ok) {
		global $wcProfile;
		$ok = $wcProfile->allowedAny(WC_PERM_USER_EDIT, WC_PERM_USER_SELF_EDIT);
	}
	//
	// Ok, everything ok.
	if($ok) {
		global $wcAction;
		global $wcThemeAssigns;

		$wcThemeAssigns["userid"] = $user->id;
		$wcThemeAssigns["useravatar"] = $user->data()->avatar();
		//
		// One more check and we are done.
		$ok = ($wcAction == WC_ACTION_USER_EDIT && !in_array($user->id, array(
			WC_USER_ROOT_ID,
			WC_USER_CRON_ID
		)));
	}

	return $ok;
}
?>
